package com.skycong.hello77.activity.personhome;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.skycong.hello77.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wangqi on 18/1/10.
 */

public class PersonHomeActivity extends Activity implements AdapterView.OnItemClickListener {
    private GridView gridView;
    private TextView username;
    private SimpleAdapter sim_adapter;
    private List<Map<String,Object>> dataList;

    private int[] pic={
            R.mipmap.dingdan_empty_icon,
            R.mipmap.close_btn,
            R.mipmap.disclosurearrow_new,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon};
    private String[] text = {
            "订单配送",
            "门店配送",
            "门店结算",
            "我的工资",
            "意见反馈"};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_home);


        gridView = (GridView) findViewById(R.id.grid_view1);
        username = (TextView) findViewById(R.id.person_name);
        //gridView布局
        dataList  = new ArrayList<Map<String,Object>>();
        sim_adapter = new SimpleAdapter(
                this,getData(),
                R.layout.person_item,
                new String[]{"pic","text"},
                new int[]{R.id.pic,R.id.text});
        gridView.setAdapter(sim_adapter);
        //为视图绑定点击事件
        gridView.setOnItemClickListener(this);

        //得到登录界面传过来的数据
        Intent intent = getIntent();
        String user = intent.getStringExtra("data");
        username.setText(user);
    }
    private List<Map<String,Object>> getData(){
        for(int i =0;i<pic.length;i++){
            Map<String,Object> map = new HashMap();
            map.put("pic",pic[i]);
            map.put("text",text[i]);
            dataList.add(map);
        }

        return dataList;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        switch (text[position]){
            case "订单配送":
            {
                break;
            }

        }
    }
}
